parameters:
  PublishRidAgnosticPackagesFromPlatform: windows_x64
  publishingInfraVersion: 3

stages:

- stage: PrepareForPublish
  displayName: Prepare for Publish
  variables:
  - template: /eng/common/templates/variables/pool-providers.yml
  jobs:
  # Prep artifacts: sign them and upload pipeline artifacts expected by stages-based publishing.
  - template: /eng/pipelines/official/jobs/prepare-signed-artifacts.yml
    parameters:
      PublishRidAgnosticPackagesFromPlatform: ${{ parameters.PublishRidAgnosticPackagesFromPlatform }}

  # Publish to Build Asset Registry in order to generate the ReleaseConfigs artifact.
  - template: /eng/common/templates/job/publish-build-assets.yml
    parameters:
      publishUsingPipelines: true
      publishAssetsImmediately: true
      dependsOn: PrepareSignedArtifacts
      pool:
        name: $(DncEngInternalBuildPool)
        demands: ImageOverride -equals 1es-windows-2022
      symbolPublishingAdditionalParameters: '/p:PublishSpecialClrFiles=true'

# Stages-based publishing entry point
- template: /eng/common/templates/post-build/post-build.yml
  parameters:
    publishingInfraVersion: ${{ parameters.publishingInfraVersion }}
    validateDependsOn:
    - PrepareForPublish
    # The following checks are run after the build in the validation and release pipelines
    # And thus are not enabled here. They can be enabled for dev builds for spot testing if desired
    enableSymbolValidation: false
    enableSigningValidation: false
    enableNugetValidation: false
    enableSourceLinkValidation: false
    publishAssetsImmediately: true
    SDLValidationParameters:
      enable: false
      artifactNames:
      - PackageArtifacts
      - BlobArtifacts
      params: >-
        -SourceToolsList @("policheck","credscan")
        -TsaInstanceURL "$(TsaInstanceURL)"
        -TsaProjectName "$(TsaProjectName)"
        -TsaNotificationEmail "$(TsaNotificationEmail)"
        -TsaCodebaseAdmin "$(TsaCodebaseAdmin)"
        -TsaBugAreaPath "$(TsaBugAreaPath)"
        -TsaIterationPath "$(TsaIterationPath)"
        -TsaRepositoryName "$(TsaRepositoryName)"
        -TsaCodebaseName "$(TsaCodebaseName)"
        -TsaPublish $True
    symbolPublishingAdditionalParameters: '/p:PublishSpecialClrFiles=true'
    # Publish to blob storage.
    publishInstallersAndChecksums: true
